/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"FE8792E9-E0A9-4897-9B10-5DCA174B447D",variableType:8}
 */
var f_importe_desde = null;

/**
 * @type {Number}
 *
 * @properties={typeid:35,uuid:"C06B91BC-BC1F-45C2-8C1C-0A6537BF3713",variableType:8}
 */
var f_importe_hasta = null;

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"02C598D8-44E1-4539-8652-011C5951B0E1"}
 */
function Ira_detalle(event) 
{
	globals.mostrarForm("fac_dtl")
}

/**
 *
 * @properties={typeid:24,uuid:"C5256EE5-201D-45D0-8B02-7B9E1CB63F04"}
 * @AllowToRunInFind
 */
function buscar() 
{
	var estado = controller.find()
	if (estado == false)
	{
		globals.DIALOGS.showWarningDialog('Aviso','No encontró Comprobantes (1º find)','OK')	
		return false;
	}
		
	cliente_id = globals.gClienteDesde
	if (globals.gFechaDesde && globals.gFechaHasta)
	{
		var d1 = globals.gFechaDesde
		d1.setHours(00);
		d1.setMinutes(00);
		d1.setSeconds(00);             
		var df1 = utils.dateFormat(d1, 'dd-MM-yyyy HH:mm:ss')
		
		var d2 = globals.gFechaHasta
		d2.setHours(23);
		d2.setMinutes(59);
		d2.setSeconds(59);
		var df2 = utils.dateFormat(d2, 'dd-MM-yyyy HH:mm:ss');
		
		fecha = df1 + '...' + df2+'|dd-MM-yyyy HH:mm:ss';	
	}
	if (f_importe_desde != null && f_importe_hasta != null)	
	{
		total = f_importe_desde + '...' + f_importe_hasta;
	}
	var found = controller.search();
	if (found == 0)
	{
		globals.DIALOGS.showWarningDialog('Aviso','No encontró Comprobantes en ese rango','OK')	
	}
	else
	{
		controller.sort('fecha desc,tipo_doc asc,nro_factura desc');
	}
	return true
}

/**
 * Handle changed data.
 *
 * @param {Object} oldValue old value
 * @param {Object} newValue new value
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"0A85EF31-F680-4B02-9C31-F0AA8193A92D"}
 */
function onDataChange_importe_desde(oldValue, newValue, event) 
{
	if (f_importe_hasta==null || f_importe_hasta<f_importe_desde)
		f_importe_hasta=f_importe_desde;
	return true
}

/**
 *
 * @properties={typeid:24,uuid:"6D195E28-2978-46CE-A6EC-8A4B00A177E3"}
 */
function iniciar() 
{
	if (!globals.gFechaDesde || !globals.gFechaHasta)
	{
		globals.gFechaHasta = new Date();
		globals.gFechaDesde = new Date();
		globals.gFechaDesde = globals.gFechaDesde.setDate (globals.gFechaHasta.getDate() - 30);
	}
	buscar()
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"96AEFC2E-A9D2-4147-89E5-8A0565765560"}
 * @AllowToRunInFind
 */
function todos(event) {
	controller.loadAllRecords()
}
